#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct Node
{
    int a, b;
};

bool operator < ( const Node &a, const Node &b )
{
    return a.a + a.b < b.a + b.b;
}

int n, h, f[ 2001 ][ 2001 ];
Node a[ 2001 ];

int main( )
{
    int i, j, s, ans, p;
    while ( scanf("%d", &n) != EOF )
    {
        s = 0;
        for ( i = 0; i < n; i++ )
        {
            scanf("%d%d", &a[ i ].a, &a[ i ].b);
            s += a[ i ].a;
        }
        scanf("%d", &h);
        sort( a, a + n );
        memset( f, -1, sizeof( f ) );
        f[ 0 ][ 0 ] = s;
        for ( i = 1; i <= n; i++ )
        {
            f[ i ][ 0 ] = s;
            for ( j = 1; j <= i; j++ )
            {
                f[ i ][ j ] = f[ i - 1 ][ j ];
                if ( f[ i - 1 ][ j - 1 ] != -1 && f[ i - 1 ][ j - 1 ] + a[ i - 1 ].b >= h && f[ i ][ j ] < f[ i - 1 ][ j - 1 ] - a[ i - 1 ].a )
                    f[ i ][ j ] = f[ i - 1 ][ j - 1 ] - a[ i - 1 ].a;
            }
        }
        for ( i = 0; i <= n; i++ )
            if ( f[ n ][ i ] >= 0 )
                ans = i;
        printf("%d\n", ans);
    }
    return 0;
}
